package com.flats.service.transactional;

import com.flats.model.dao.Dao;
import com.flats.model.entity.Flat;
import com.flats.service.FlatService;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

@Transactional
public class TransactionalFlatService implements FlatService {

    private Dao<Flat> flatDao;

    public void setFlatDao(Dao<Flat> flatDao) {
        this.flatDao = flatDao;
    }


    @Override
    @Transactional
    public Serializable saveOrUpdate(Flat persistent) {
        return flatDao.saveOrUpdate(persistent);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        flatDao.delete(id);
    }

    @Override
    @Transactional
    public void delete(Flat persistent) {
        flatDao.delete(persistent);
    }

    @Override
    @Transactional
    public Flat get(Long id) {
        return flatDao.get(id);
    }

    @Override
    @Transactional
    public List<Flat> getAll() {
        return flatDao.getAll();
    }
}
